import 'package:common/base/base_widget.dart';
import 'package:common/common.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_mobile_app/router_manager.dart';

/// 前端主视图
class Program extends ConsumerWidget {
  const Program({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context, WidgetRef ref) {
    ScreenUtil.init(context, designSize: const Size(AppConstants.uiWidth, AppConstants.uiHeight));
    return MaterialApp(
        navigatorKey: AppConstants.globalKey,
        // 隐藏debug标签
        debugShowCheckedModeBanner: false,
        // 语言
        localizationsDelegates: [
          GlobalCupertinoLocalizations.delegate,
          GlobalMaterialLocalizations.delegate,
          GlobalWidgetsLocalizations.delegate,
          AppLocalizationsDelegate.delegate
        ],
        supportedLocales: supportLocale,
        locale: ref.watch(localeProvider) as Locale,
        // 样式
        theme: ThemeData(
            textTheme: ref.watch(textThemeProvider).textTheme,
            primaryColor: AppColor.primary,
            splashColor: Colors.transparent,
            highlightColor: Colors.transparent,
            colorScheme: const ColorScheme.light(primary: AppColor.primary, secondary: AppColor.primary)),
        darkTheme: ThemeData(
            textTheme: ref.watch(textThemeProvider).textTheme,
            primaryColor: AppColor.primary,
            splashColor: Colors.transparent,
            highlightColor: Colors.transparent,
            colorScheme: const ColorScheme.light(primary: AppColor.primary, secondary: AppColor.primary)),
        // 路由
        onGenerateRoute: RouterManager.generateRoute,
        home: const SimplePage(),
        // smartDialog 初始化
        navigatorObservers: [FlutterSmartDialog.observer],
        builder: FlutterSmartDialog.init());
  }
}
